package com.zoe.app.config;

import com.zoe.app.intercept.IdempotentIntercept;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @author Zoe.Zhang
 * @date 2021/10/24
 * @description
 */
@Configuration
public class WebMvcConfig implements WebMvcConfigurer {
    @Autowired
    private IdempotentIntercept idempotentIntercept;

    @Override
    public void addViewControllers(ViewControllerRegistry registry) {
        registry.addRedirectViewController("/", "/hello");
    }

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(idempotentIntercept).addPathPatterns("/**");
    }
}
